package org.karelun.gef.figure;

import org.eclipse.draw2d.BorderLayout;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.Shape;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Color;

public class RelationFigure extends NodeFigure {
	
	private class RelationShape extends Shape{

		protected void fillShape(Graphics graphics) {
			Rectangle r = getBounds();
			Rectangle rect=new Rectangle(r.x,r.y,r.width-1,r.height-1);
			graphics.fillRectangle(rect);
			graphics.drawRectangle(rect);
		}

		protected void outlineShape(Graphics graphics) {
		}
	}
	
	public RelationFigure(){
		super();
		label=new Label();
		BorderLayout layout=new BorderLayout();
		setLayoutManager(layout);
		
		RelationShape shape = new RelationShape();
		shape.add(label);
		add(shape,BorderLayout.CENTER);
		setOpaque(true);
	}
	
	@Override
	public void setBounds(Rectangle rect) {
		super.setBounds(rect);
		label.setBounds(rect);
	}
	
	@Override
	protected void setBGColor(Color color) {
		setBackgroundColor(color);
	}
}
